﻿using System.Collections.Generic;
using System.Linq;
using Xc.DataAccess.Core.Extensions;

namespace Xc.DataAccess.Protocoals.WaterMeters.Models.Requests
{
    /// <summary>
    /// 设置表计IP地址
    /// </summary>
    public class SetMeterIpAddressRequest : MeterFrameTxBase
    {
        internal protected override DataSegment DataSegment => DataSegment.SetMeterIpAddress;

       internal protected override FrameCommand Cmd => FrameCommand.CMD05;

        protected override void GetDataArea(List<byte> vs)
        {
            vs.AddRange(MasterIPaddress);
            vs.AddRange(MasterPort.FromUInt16LittleEndian());
            vs.Add((byte)MasterEnable);

            vs.AddRange(SlaveIPaddress);
            vs.AddRange(SlavePort.FromUInt16LittleEndian());
            vs.Add((byte)SlaveEnable);
            vs.AddRange(Enumerable.Repeat<byte>(0,5));
        }
        /// <summary>
        /// 主服务器地址
        /// </summary>
        public byte[] MasterIPaddress { get; set; }
        /// <summary>
        /// 主服务器端口
        /// </summary>
        public ushort MasterPort { get; set; }
        /// <summary>
        /// 主服务器启用
        /// </summary>
        public ServerSelect MasterEnable { get; set; }
        public byte[] SlaveIPaddress { get; set; }
        public ushort SlavePort { get; set; }
        /// <summary>
        /// 主服务器启用
        /// </summary>
        public ServerSelect SlaveEnable { get; set; }
    }
}
